<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>watch监听器</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
<div id="Application" style="text-align:center;">
    <input v-model="searchText">
</div>

<script>
    const App = {
        data() {
            return {
                searchText: ""
            }
        },
        watch: {
            searchText(oldValue, newValue) {
                console.log(oldValue)
                console.log(newValue)
                if (newValue.length > 10) {
                    alert("输入的太长了！")
                }

            }
        }

    }
    Vue.createApp(App).mount('#Application');
</script>

</body>
</html>
